<?php
  class Plugins_Map extends model {
  
  
  
  function getformadd($productid="")
  {
  
  
  
  
  $echo=1;
//  $str='<div class="classmap"> 
//   <div class="mapdata" style="width:640px;height:360px">textmap</div>
//   <div><input type="text" name="detail[]"><input type="hidden" name="lat[]"><input type="hidden" name="lng[]"></div>
//  </div>
//  ';
  $str='<div class="wrpPlg clBg5 clBd2 bdFull classmap">
                    <div  class="plgArea mapdata" style="width:100%;height:360px"></div>
                    <div class="wrpOutAtcPlg">
                        <div class="wrpAtcPlg">
                            <span class="ico icoOri icoMapPlg"></span>
                            <div class="spnAtcPlg clTxtW">
                                <span class="txtAtcPlg fs03">Map</span>
                            </div>
                        </div>
                    </div>
                    <div class="wrpTl">
                        <div title="Close" class="btnIco closeTl clBd3 mgBtm10 deleterowbutton">
                            <span class="ico icoCloseTl"></span>
                        </div>
                    </div>
                    <span class="desPlg clTxt3 fs03">Point out the location of this thing.</span>
                    <div class="wrpInpLct clBd2">
                        <div class="hdLct clTxtW fs02">Location</div>
                        <form class="frmLctPlg" onsubmit="return false;">
                            <input type="text" name="detail[]" placeholder="Search location here." class="inpTprPlg inpLctPlg clTxt2 fs02"><input type="hidden" name="lat[]"><input type="hidden" name="lng[]">
                            <div class="btnIco srchLct">
                                <span class="ico icoSrchGen"></span>
                            </div>
                        </form>    
                    </div>
                </div>';
  
  
  
  $arraydata['form']=addslashes(str_replace(array("\r", "", "\r"), '', $str));
//  $arraydata['js'][]=pluginjsinfo.'/map.js';
//  $arraydata['js'][]='https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=true';
 // $arraydata['js'][]=baseinfo.'/js/gmap3.js';
  //$arraydata['js'][]=baseinfo.'/js/jquery.Jcrop.min.js';
 // $arraydata['js'][]=baseinfo.'/js/jquery.iuploader-1.0.js';
  
  
      
  
  
  
  return $arraydata;
  
  
  
  
  
  
  
  }
  
  function getformlanding($arraydata)
  {
  if($arraydata['lat']!='0.000000000000000')
  {
  $code  = '<div class="ldIt wrpMapLd clBg4 w640" id="mapid'.$arraydata['mapid'].'">';
  
  $code .='<a href="http://maps.google.com/?q='.$arraydata['lat'].','.$arraydata['lng'].'" target="_blank"><img width="100%"  src="http://maps.googleapis.com/maps/api/staticmap?center='.$arraydata['lat'].','.$arraydata['lng'].'&zoom=17&size=640x640&markers='.$arraydata['lat'].','.$arraydata['lng'].'&sensor=true" ></a>';
  //$code .='<iframe width="100%" height="340" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.co.th/maps?f=q&hl=en&geocode=&q='.$arraydata['lat'].','.$arraydata['lng'].'&aq=&sll='.$arraydata['lat'].','.$arraydata['lng'].'&ie=UTF8&ll='.$arraydata['lat'].','.$arraydata['lng'].'&spn=0.008774,0.026157&t=m&z=15&output=embed"></iframe><br /><small><a href="https://maps.google.co.th/maps?f=q&source=embed&hl=en&geocode=&q='.$arraydata['lat'].','.$arraydata['lng'].'&aq=&sll='.$arraydata['lat'].','.$arraydata['lng'].'&ie=UTF8&ll='.$arraydata['lat'].','.$arraydata['lng'].'&t=m&z=15" style="color:#0000FF;text-align:left">View Larger Map</a></small>';
  $code .= '<div class="icoDefLd">'."";
  $code .= '<span class="ico icoMapDefLd"></span>'."";
  $code .= '<span>Map</span>'."";
  $code .= '</div>'."";
  
  $code .= '</div>';
  }
  $data['str']=$code;
  $data['target']='secondtarget';
 // $data['script']="initmapdata();";
  
  return $data; 
  
  }
  
  function getplugin($plugreid)
  {
  
     $sql="select * from tb_plugins_map where plugreid=".$plugreid;
     $arrayplugin=$this->db->db_set_1recordrow($sql);
     
     if($_GET['lat']&&$_GET['lng']&&$arrayplugin['lat']&& $arrayplugin['lng'])
     {
     $arrayplugin['show']=number_format(distancelatlng($_GET['lat'], $_GET['lng'], $arrayplugin['lat'], $arrayplugin['lng']), 2, '.', '').' Km';
     }else
     {
     $arrayplugin['show']="";
     }
     
     
  
     return $arrayplugin;

  
  
  

  
  }
  function saveplugin($arraydata,$productid,$plugreid)
  {
  
  $arraydata['productid']=$productid;
  $arraydata['plugreid']=$plugreid;
  $this->db->db_set($arraydata,'tb_plugins_map');
  
  }
  
  
  }
?>
